﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;

namespace Nirvana
{
    [CustomPropertyDrawer(typeof(SortLayerAttribute))]
    public sealed class SortLayerPropertyDrawer : PropertyDrawer
    {
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var layers = SortingLayer.layers;
            string[] layername = new string[layers.Length];
            int[] layerid = new int[layers.Length];
            for (int i = 0; i < layers.Length; i++)
            {
                layerid[i] = layers[i].id;
                layername[i] = string.Format("{0}: {1}", i,layers[i].name);
            }
            property.intValue = EditorGUI.IntPopup(position, label.text, property.intValue, layername, layerid);

        }

    }
}

